package com.hdsx.jxcsxm.log.strategy.impl;

import com.hdsx.jxcsxm.log.bean.SysLog;
import com.hdsx.jxcsxm.log.strategy.IOperatStrategy;
import com.hdsx.jxcsxm.log.type.BusinessType;
import com.hdsx.jxcsxm.log.util.CommonUtils;
import com.opensymphony.xwork2.ActionInvocation;
import org.apache.struts2.dispatcher.HttpParameters;
import org.apache.struts2.dispatcher.Parameter;

import javax.servlet.http.HttpServletRequest;

/**
 * @author 占贤银
 * time 2023/10/24 16:38
 * description 生命之灯因热情而点燃，生命之舟因拼搏而前行
 */
public class UpdateTypeStrategy implements IOperatStrategy {
    @Override
    public SysLog operate(ActionInvocation invocation, HttpServletRequest request) {
        final HttpParameters parameters = invocation.getInvocationContext().getParameters();
        boolean isContains = parameters.contains("shzt");
        boolean isSfth = parameters.contains("sfth");
        BusinessType businessType = null;
        if (isContains) {
            String string = parameters.get("shzt").toString();
            System.out.println("string = " + string);
            if (string.indexOf("已审核") != -1) {
                // todo 已审核
                businessType = BusinessType.SHZT_TYPE;
            } else {
                // todo 退回未审核
                businessType = BusinessType.THWSH_TYPE;
            }
        } else {
            String sfthStr = parameters.get("sfth").toString();
            if (sfthStr.indexOf("是") != -1) {
                // todo 退回
                businessType = BusinessType.TH_TYPE;
            } else {
                // todo 上报
                businessType = BusinessType.SBZT_TYPE;
            }
        }
        return CommonUtils.getCommonSyslog_insert(invocation, request, businessType);
    }
}
